
#@layout()
#define css()
#@layout_css?()
<link rel="stylesheet" href="#(CPATH)/static/components/datepicker/css/bootstrap-datepicker3.min.css">
<link rel="stylesheet" href="#(CPATH)/static/components/jquery-file-upload/css/jquery.fileupload.css">
<style>
	#uploader {
		height: 230px;
	}
	.myPanel {
		font-size: 25px;
		color: #ccc;
		text-align: center;
		padding-top: 60px;
	}
</style>
#end
#define script()
<script src="#(CPATH)/static/components/ckeditor/ckeditor.js"></script>
<script src="#(CPATH)/static/components/jquery-file-upload/js/vendor/jquery.ui.widget.js"></script>
<script src="#(CPATH)/static/components/jquery-file-upload/js/jquery.iframe-transport.js"></script>
<script src="#(CPATH)/static/components/jquery-file-upload/js/jquery.fileupload.js"></script>
#@layout_script?()
<script src="#(CPATH)/static/components/datepicker/js/bootstrap-datepicker.min.js"></script>
<script src="#(CPATH)/static/components/datepicker/locales/bootstrap-datepicker.zh-CN.min.js"></script>
<script>
    $("input[hint='date']").datepicker({
        format: 'yyyy-mm-dd',
        language: 'zh-CN'
    });

  function doSubmit() {

	  var checkboxs = $("#xzk input[type='checkbox']:checked")
	  if(checkboxs.length<1){
		  alert("至少要选择一个用户");
		  return;
	  }

    ajaxSubmit("#form", function (data) {
        $("#entryId").attr("value", data.id);
        toastr.success('内容保存成功。');
        location.href="/admin/servicebulletins/jpress_addon_servicebulletins";
    })
  }

    $("#submit").on("click", function () {
        doSubmit();
    })

	initEditor('editor1', 267,"html");

	$("#attachments-1").hide()
	$("#attachments-2").hide()

    </script>
<script>
	$('#cfile').fileupload({
		dropZone: $('#uploader'),
		url: '#(CPATH)/commons/attachment/upload',
		sequentialUploads: true,
		progressall: function (e, data) {
			var progress = parseInt(data.loaded / data.total * 100, 10);
			$(".fj1").text("上传进度：" + progress + "%")
		},
		done: function (e, data) {

			$(".fj1").text("或者拖动文件到这里进行上传...");

			if(data.result.state == "ok"){
				$("#attachment").val(data.result.src);
				toastr.success("文件上传成功...")
				$("#attachments-1").show();
				$("#attachments-1-a").attr("href",data.result.src);
			}else {
				toastr.error(data.result.message)
			}
		}
	});

</script>
<script>
	$('#cfile1').fileupload({
		dropZone: $('#uploader1'),
		url: '#(CPATH)/commons/attachment/upload',
		sequentialUploads: true,
		progressall: function (e, data) {
			var progress = parseInt(data.loaded / data.total * 100, 10);
			$(".fj2").text("上传进度：" + progress + "%")
		},
		done: function (e, data) {

			$(".fj2").text("或者拖动文件到这里进行上传...");

			if(data.result.state == "ok"){
				$("#attachment1").val(data.result.src);
				toastr.success("文件上传成功...")
				$("#attachments-2").show();
				$("#attachments-2-a").attr("href",data.result.src);
			}else {
				toastr.error(data.result.message)
			}
		}
	});

</script>
<script>
	function updateui (){
		var checkboxs = $("#xzk input[type='checkbox']:checked");
		var data = "";
		console.log(data);
		console.log(checkboxs);
		for(var a=0;a<checkboxs.length;a++){
			data += " | " + $(checkboxs[a]).attr("mytext");
		}
		$("#username").html(data);
	}
</script>
#end


#define content()

<div class="content-wrapper">

    <section class="content-header">
        <h1>
                        编辑/新增
            <small>Edit</small>
        </h1>
    </section>

    <section class="content">

        <div class="row">
            <div class="col-xs-12">
                <div class="box box-primary">
                    <div class="box-header ">
                        <h3 class="box-title"></h3>
                    </div>
                    <form class="form-horizontal form-setting" autocomplete="off"
                          action="/admin/servicebulletins/jpress_addon_servicebulletins/doSave"
                          method="POST" id="form">

                        <div class="box-body ">
	                                <input type="hidden" id="entryId" name="jpressAddonServicebulletins.id" value="#(jpressAddonServicebulletins.id ??)">
									<div class="form-group">
										<label class="col-sm-2 control-label">可见用户</label>
										<div class="col-sm-6">

											<!-- Modal -->
											<div class="modal fade" id="exampleModalScrollable" tabindex="-1" role="dialog" aria-labelledby="exampleModalScrollableTitle" aria-hidden="true">
												<div class="modal-dialog modal-dialog-centered" role="document">
													<div class="modal-content">
														<div class="modal-header">
															<h5 class="modal-title" id="exampleModalScrollableTitle">用户选择</h5>
															<button type="button" class="close" data-dismiss="modal" aria-label="Close">
																<span aria-hidden="true">&times;</span>
															</button>
														</div>
														<div class="modal-body" style="height:400px;overflow:auto;right: 1px;" id="xzk">
															#UserTagList()
																#for(utl:UserTagList)
																	<div style="text-align: center">
																		<h3>#(utl.title)</h3>
																	</div>
																	<ul class="list-group">
																		#UserByTagList(id=utl.id)
																			#for(ubtl:UserByTagList)
																				#UserByIdList(id=ubtl.user_id)
																					#for(ubil:UserByIdList)
																					<li class="list-group-item">
																						<input class="form-check-input" type="checkbox" value="#(ubil.id ??)" name="userid" mytext="#(ubil.username ??)#if(ubil.nickname)(#(ubil.nickname ??))#end"
																						   #if(sbu)
																							#for(u1 : sbu)
																							   #if(ubil.id.toString() == u1.user_id.toString())
																								checked="checked"
																							   #break
																							   #end
																							#end
																						   #end
																						>
																						<label class="form-check-label">
																							#(ubil.username ??)#if(ubil.nickname)(#(ubil.nickname ??))#end
																						</label>
																					</li>
																					#end
																				#end
																			#end
																		#end
																	</ul>
																#end
															#end
														</div>
														<div class="modal-footer" onclick="updateui();">
															<button type="button" class="btn btn-secondary" data-dismiss="modal">关闭</button>
														</div>
													</div>
												</div>
											</div>

											<!-- Button trigger modal -->
											<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModalScrollable">
												选择
											</button>
											<div id="username">
												#if(sbu)
												#for(e : sbu)
												#UserByIdList(id=e.user_id)
													#for(user : UserByIdList)
														| #(user.username)(#(user.nickname))
													#end
												#end
												#end
												#end
											</div>
										</div>
									</div>
									<div class="form-group">
										<label class="col-sm-2 control-label">紧急程度</label>
										<div class="col-sm-6">
<!--											<input type="input" name="jpressAddonServicebulletins.emergency_level" class="form-control" value="#(jpressAddonServicebulletins.emergency_level ??)"-->
<!--												   placeholder="">-->
											<select class="form-control" name="jpressAddonServicebulletins.emergency_level">
												<option #if(jpressAddonServicebulletins) #if(jpressAddonServicebulletins.emergency_level =='普通') selected #end #end value="普通">普通</option>
												<option #if(jpressAddonServicebulletins) #if(jpressAddonServicebulletins.emergency_level =='重要') selected #end #end value="重要">重要</option>
												<option #if(jpressAddonServicebulletins) #if(jpressAddonServicebulletins.emergency_level =='紧急') selected #end #end value="紧急">紧急</option>
											</select>
										</div>
									</div>
									<div class="form-group">
		                                <label class="col-sm-2 control-label">通告编号</label>
		                                <div class="col-sm-6">

										   <input type="input" name="jpressAddonServicebulletins.circular_number" class="form-control" value="#(jpressAddonServicebulletins.circular_number ??)"
		                                           placeholder="">
		                                </div>
		                            </div>
		                            <div class="form-group">
		                                <label class="col-sm-2 control-label">版次</label>
		                                <div class="col-sm-6">

										   <input type="input" name="jpressAddonServicebulletins.edition" class="form-control" value="#(jpressAddonServicebulletins.edition ??)"
		                                           placeholder="">
		                                </div>
		                            </div>
		                            <div class="form-group">
		                                <label class="col-sm-2 control-label">标题</label>
		                                <div class="col-sm-6">

										   <input type="input" name="jpressAddonServicebulletins.title" class="form-control" value="#(jpressAddonServicebulletins.title ??)"
		                                           placeholder="">
		                                </div>
		                            </div>
		                            <div class="form-group">
		                                <label class="col-sm-2 control-label">英文标题</label>
		                                <div class="col-sm-6">

										   <input type="input" name="jpressAddonServicebulletins.title_en" class="form-control" value="#(jpressAddonServicebulletins.title_en ??)"
		                                           placeholder="">
		                                </div>
		                            </div>
		                            <div class="form-group">
		                                <label class="col-sm-2 control-label">颁发单位</label>
		                                <div class="col-sm-6">

										   <input type="input" name="jpressAddonServicebulletins.lssuing_unit" class="form-control" value="#(jpressAddonServicebulletins.lssuing_unit ??)"
		                                           placeholder="">
		                                </div>
		                            </div>
									<div class="form-group">
										<label class="col-sm-2 control-label">颁发单位英文</label>
										<div class="col-sm-6">

											<input type="input" name="jpressAddonServicebulletins.lssuing_unit_en" class="form-control" value="#(jpressAddonServicebulletins.lssuing_unit_en ??)"
												   placeholder="">
										</div>
									</div>
		                            <div class="form-group">
		                                <label class="col-sm-2 control-label">发布日期</label>
		                                <div class="col-sm-6">

										    <input type="input" class="form-control datetimepicker" placeholder="点击选择"
		                       						name="jpressAddonServicebulletins.release_date" value="#date(jpressAddonServicebulletins.release_date ?? now,'yyyy-MM-dd')" >
		                                </div>
		                            </div>
		                            <div class="form-group">
		                                <label class="col-sm-2 control-label">机型</label>
		                                <div class="col-sm-6">

											<select class="form-control" name="jpressAddonServicebulletins.model">
												#articleMetaList(id=2)
												#for(str:values)
												<option #if(jpressAddonServicebulletins) #if( jpressAddonServicebulletins.model==str) selected #end#end value="#(str ??)">
													#(str ??)
												</option>
												#end
												#end
											</select>

		                                </div>
		                            </div>
									<div class="form-group" id="attachments-1">
										<label class="col-sm-2 control-label">已上传</label>
										<div class="col-sm-6">
											<a href="" id="attachments-1-a">下载附件</a>
										</div>
									</div>
									#if(jpressAddonServicebulletins.enclosure ??)
									<div class="form-group">
										<label class="col-sm-2 control-label">历史附件</label>
										<div class="col-sm-6">
											<a href="#(jpressAddonServicebulletins.enclosure ??)">下载附件</a>
										</div>
									</div>
									#end
									<div class="form-group">
										<label class="col-sm-2 control-label">附件</label>
										<div class="col-sm-6">
											<input id="attachment" type="hidden" name="jpressAddonServicebulletins.enclosure" value="#(jpressAddonServicebulletins.enclosure ??)"/>
											<div id="uploader">
														<span class="btn btn-block btn-primary fileinput-button" style="width: 120px">
															<i class="glyphicon glyphicon-plus"></i>
															<span>选择文件...</span>
															<input id="cfile" type="file" name="files[]" multiple>
														</span>
												<div class="myPanel fj1">
													或者拖动文件到这里进行上传...
												</div>
											</div>
										</div>
									</div>
									<div class="form-group" id="attachments-2">
										<label class="col-sm-2 control-label">已上传</label>
										<div class="col-sm-6">
											<a href="" id="attachments-2-a">下载附件</a>
										</div>
									</div>
									#if(jpressAddonServicebulletins.enclosure_en ??)
									<div class="form-group">
										<label class="col-sm-2 control-label">历史附件英文</label>
										<div class="col-sm-6">
											<a href="#(jpressAddonServicebulletins.enclosure_en ??)">下载附件英文</a>
										</div>
									</div>
									#end
									<div class="form-group">
										<label class="col-sm-2 control-label">附件英文</label>
										<div class="col-sm-6">
											<input id="attachment1" type="hidden" name="jpressAddonServicebulletins.enclosure_en" value="#(jpressAddonServicebulletins.enclosure_en ??)"/>
											<div id="uploader1">
																<span class="btn btn-block btn-primary fileinput-button" style="width: 120px">
																	<i class="glyphicon glyphicon-plus"></i>
																	<span>选择文件...</span>
																	<input id="cfile1" type="file" name="files[]" multiple>
																</span>
												<div class="myPanel fj2">
													或者拖动文件到这里进行上传...
												</div>
											</div>
										</div>
									</div>
									<div class="form-group">
										<label class="col-sm-2 control-label">详情</label>
										<div class="col-sm-8" style="z-index: 9999;">
													<textarea id="editor1" name="jpressAddonServicebulletins.content"
															  style="height: 467px;width: 100%;background-color: white">#EditorContent(jpressAddonServicebulletins.content ??)</textarea>
										</div>

									</div>


                        </div>
                        <!-- /.box-body -->
                        <div class="box-footer">
                            <div class="col-sm-offset-2 col-sm-10 submit-block">
                                <div class="box-submit">
                                    <button id="submit" type="button" class="btn btn-primary">提交</button>
                                </div>
                            </div>
                        </div>
                        <!-- /.box-footer -->
                    </form>
                </div>
            </div>
        </div>

    </section>

</div>
#end
